package com.example.springboot01.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.springboot01.config.ServiceException;
import com.example.springboot01.model.ManageAccount;
import com.example.springboot01.mapper.ManageAccountMapper;
import com.example.springboot01.service.ManageAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zrd
 * @since 2022-06-03
 */
@Service
public class ManageAccountServiceImpl extends ServiceImpl<ManageAccountMapper, ManageAccount> implements ManageAccountService {

    //根据用户名，密码查询用户id
    @Override
    public String getUserIdByAdminNameAndPassword(String adminName, String password) {
        ManageAccount manageAccount = getOne(new QueryWrapper<ManageAccount>()
                .eq("admin_name",adminName)
                .eq("password",password));
        if (manageAccount == null){
            throw new ServiceException("用户名，密码不正确");
        }
        return manageAccount.getId();
    }
}
